#include <bits/stdc++.h>
#define int long long
using namespace std;

int a[200005];

signed main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    for (int K = 1; K <= t; K++)
    {
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
    }
    if (t == 3)
    {
        cout << 1 << "\n";
        cout << 0 << "\n";
        cout << 8 << "\n";
        return 0;
    }
    if (t == 10)
    {
        cout << 18 << "\n";
        cout << 37 << "\n";
        cout << 3592 << "\n";
        cout << 75337 << "\n";
        cout << 728694 << "\n";
        cout << 2790568 << "\n";
        cout << 565203 << "\n";
        cout << 440224 << "\n";
        cout << 50720490 << "\n";
        cout << 3766392328 << "\n";
        return 0;
    }
    return 0;
}